package org.hairball.analysis;

import org.objectweb.asm.tree.ClassNode;

import java.io.IOException;
import java.io.InputStream;

class ClassNodeFixture {

    private static InputStream getClassBytecode(Class rootClass, Class staticInnerClass) {
        return rootClass.getResourceAsStream(rootClass.getSimpleName() +
                "$" +
                staticInnerClass.getSimpleName() +
                ".class");
    }

    private static InputStream getClassBytecode(Class aClass) {
        return aClass.getResourceAsStream(
                aClass.getSimpleName() +
                ".class");
    }

    public static ClassNode getClassNode(Class rootClass, Class staticInnerClass) throws IOException {
        return new ClassNodeFactory().getClassNodeForBytecode(getClassBytecode(rootClass, staticInnerClass));
    }

    public static ClassNode getClassNode(Class aClass) throws IOException {
        return new ClassNodeFactory().getClassNodeForBytecode(getClassBytecode(aClass));
    }


}
